﻿using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 超市收银台
{
    public partial class SelectGoodsForm2 : Form
    {
        private List<GoodsInfo> list = new List<GoodsInfo>();

        public SelectGoodsForm2(List <GoodsInfo> a)
        {

            InitializeComponent();
            list = a;
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void SelectGoodsForm2_Load(object sender, EventArgs e)
        {
            dataGridView2.AutoGenerateColumns = false;
            //Form1 cs = new Form1();
            
            GoodsService gs = new GoodsService();
             //d = cs.chuansongshuju();
           // MessageBox.Show("2"+d);
            dataGridView2.DataSource = new BindingList<GoodsInfo>(list);

            
            
            

            
        }
        
        public  GoodsInfo goods { get; set; }
        private void dataGridView2_KeyUp(object sender, KeyEventArgs e)
        {
            if(e.KeyCode==Keys.Enter)
            {
                if(dataGridView2.SelectedRows.Count==1)
                {
                    int index = dataGridView2.SelectedRows[0].Index;
                    goods = list[index - 1];
                    this.Close();

                }
                

            }
        }
    }
}
